# _*_ coding: utf-8 _*_
from odoo import models, fields, api


class PurchaseRequisitionCancel(models.TransientModel):
    _name = "purchase.requisition.cancel"

    cancel_reason = fields.Text(string="Cancel Reason", required=True)

    def action_ok(self):
        self.ensure_one()
        purchase_requisition = self.env["purchase.requisition"].browse(self.env.context.get("active_id"))
        if purchase_requisition:
            purchase_requisition.cancel_reason = self.cancel_reason
            purchase_requisition.action_cancel()
